package com.toocms.jinjuhang.ui.web

import android.webkit.WebChromeClient
import android.webkit.WebView
import com.qmuiteam.qmui.widget.webview.QMUIWebViewClient
import com.toocms.jinjuhang.R
import com.toocms.jinjuhang.BR
import com.toocms.jinjuhang.config.Constants
import com.toocms.jinjuhang.databinding.FgtWebBinding
import com.toocms.jinjuhang.ui.base.BaseFgt

class WebFgt : BaseFgt<FgtWebBinding, WebModel>() {
    override fun onFragmentCreated() {
        binding.contentWv.apply {
            settings.apply {
                javaScriptEnabled = true
                databaseEnabled = true
                displayZoomControls = false
                setSupportZoom(false)
            }
            webViewClient = QMUIWebViewClient(true, true)
            webChromeClient = object : WebChromeClient() {
                override fun onReceivedTitle(view: WebView?, title: String?) {
                    super.onReceivedTitle(view, title)
                    topBar.setTitle(title)
                }
            }
            loadUrl(requireArguments().getString(Constants.BundleKey.KEY_URL, ""))
        }
    }

    override fun getLayoutResId() = R.layout.fgt_web

    override fun getVariableId() = BR.webModel

    override fun viewObserver() {

    }
}